-- kill_living_recover
-- created by zhuangsl
-- 击杀敌人增加属性N

return {
    apply = function(prop, baseValue)
        return baseValue + prop[3];
    end,

    -- 击杀触发
    trigger = function(who, prop, arg)

        local attrib = prop[2];
        local value  = prop[3];

        local specialProp = PropM.combine(who, "prop_force_add", prop[1]);
        if specialProp[3] > 0 then
            value = PropM.apply(specialProp, value);
        end

        if attrib == "hp" or attrib == "mp" then
            local maxAttrib = "max_"..attrib;
            value = math.min(who:queryAttrib(maxAttrib) - who:queryAttrib(attrib), value);
            BonusM.doBonus({ 2, attrib, value, }, "prop kill_living_recover");
            -- 增加一点属性上限，但回复不能超过上限
            BonusM.doBonus({ 2, maxAttrib, 1, }, "prop kill_living_recover");
        else
            BonusM.doBonus({ 2, attrib, value, }, "prop kill_living_recover");
        end

        if value > 0 and attrib == "hp" then
            -- 触发特技发动事件
            EventMgr.fire(event.SPECIAL_SKILL_TRIGGER, { propId = prop[1] });
        end

        return prop[3];
    end,

    record = function(target, prop, path)
        return false;
    end
};
